{include file="../include.tpl"}
<!-- production -->
<script type="text/javascript" src="js/plupload.full.min.js"></script>
<!-- debug 
<script type="text/javascript" src="../js/moxie.js"></script>
<script type="text/javascript" src="../js/plupload.dev.js"></script>
-->
<body>
{literal}
<style>
#ulList{list-style:none; padding:0; margin:0;width:97%; margin-top:30px;}
#ulList li{float:left;width:200px;height:240px;position: relative; text-align:center; padding-left:32px;}
#ulList li table{width:200px;height:240px;text-align:center;}
#ulList li img{width:130px;height:100px; cursor:pointer;}
#ulList li p{width:130px;height:100px; cursor:pointer; position:absolute;top:0px; line-height:100px; text-align:center;}

.tblFile td{border:#CCC 1px solid}
#filelist div{height:30px; line-height:30px;}
.btn{ background-color:#597ddb; color:#ffffff; border:0;height:30px;}
</style>

{/literal}
<iframe name="iframeSubmit" id="iframeSubmit" src="about:blank" style="display:none;"></iframe>
 {include file='header.tpl'}
<table width="1000" style="margin:auto;" border="0" cellpadding="0" cellspacing="0">
   
  <tr>
    <td height="71" valign="middle" >&nbsp;</td>
    <td valign="top"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          
          <tr>
            <td>
            <div id="users-contain" class="ui-widget" style="width:100%;">
 
            <div id="filelist"></div>

	<table id="users" class="ui-widget ui-widget-content" height="400">
		<tbody>
         <tr>
              <td  style="text-align:center;" valign="top">
              <ul id="ulList">       
<li id="up1"><table><tr><td align="center"><input type="hidden" id="imgPath" value="{$data[0].pic}" /><img id="up" src="{$data[0].pic}" /><p></p></td></tr><tr><td>链接主题<input type="text"  id="subject" value="{$data[0].subject}"/></td></tr><tr><td><input class="btn" type="button" id="btnPost" value='完成发布'/></td></tr><tr><td><input type="button" class="btn" id="btnUnpost" value='删除'/></td></tr></table></li>
<li id="up2"><table><tr><td align="center"><input type="hidden" id="imgPath" value="{$data[1].pic}" /><img id="up"src="{$data[1].pic}" /><p></p></td></tr><tr><td>链接主题<input type="text" id="subject" value="{$data[1].subject}"/></td></tr><tr><td><input class="btn" type="button" id="btnPost" value='完成发布'/></td></tr><tr><td><input type="button" class="btn" id="btnUnpost" value='删除'/></td></tr></table></li>
<li id="up3"><table><tr><td align="center"><input type="hidden" id="imgPath" value="{$data[2].pic}" /><img id="up" src="{$data[2].pic}"/><p></p></td></tr><tr><td>链接主题<input type="text" id="subject" value="{$data[2].subject}"/></td></tr><tr><td><input class="btn" type="button" id="btnPost" value='完成发布'/></td></tr><tr><td><input type="button" id="btnUnpost" class="btn" value='删除'/></td></tr></table></li>
<li id="up4"><table><tr><td align="center"><input type="hidden" id="imgPath" value="{$data[3].pic}" /><img id="up" src="{$data[3].pic}"/><p></p></td></tr><tr><td>链接主题<input type="text" id="subject" value="{$data[3].subject}"/></td></tr><tr><td><input class="btn" type="button" id="btnPost" value='完成发布'/></td></tr><tr><td><input type="button" id="btnUnpost" class="btn" value='删除'/></td></tr></table></li>
              </ul>
              </td>
         </tr>
		</tbody>
	</table>
</div>
 </td>
          </tr>
        </table>
          </td>
      </tr>
    </table></td>
    <td >&nbsp;</td>
  </tr>
   <tr>
        <td  colspan="3" height="30" valign="middle">
     
    </td>
  </tr>
  <tr>
    <td  colspan="3" valign="middle">
     {include file='footer.tpl'} 
    </td>

  </tr>
</table>
<form action="?act={$act}&op=saveRef" method="post" id="form" target="iframeSubmit">
<input type="hidden" id="dbsubject" name="dbsubject"/>
<input type="hidden" id="pic" name="dbpic"/>
<input type="hidden" id="id" name="id"/>
<input type="hidden" id="post" name="isPost"/>
</form>
</body>
 {literal}
<script type="text/javascript">
var up1,up2,up3,up4;
 function newUploader(button,status)
 {
 	var uploader = new plupload.Uploader({
	runtimes : 'html5,flash,silverlight,html4',
	browse_button : $("#"+button).find("img")[0], // you can pass in id...
	container: document.getElementById('users-contain'), // ... or DOM Element itself
	url : 'upload.php',
	flash_swf_url : 'js/Moxie.swf',
	silverlight_xap_url : 'js/Moxie.xap',
	chunk_size:"1mb",
	filters : {
		max_file_size : '1000mb',
		mime_types: [
			{title : "Image files", extensions : "jpg,gif,png"}
		]
	},

	init: {
		PostInit: function() {
			document.getElementById('filelist').innerHTML = '';

			//document.getElementById('uploadfiles').onclick = function() {
			//	uploader.start();
			//	return false;
			//};
		},

		FilesAdded: function(up, files) {
			plupload.each(files, function(file) {
				//document.getElementById(status).innerHTML += '<div id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></div>';
				uploader.start();
				//document.getElementById('filelist').innerHTML += '<table width="100%" class="tblFile" id="tblFile_'+file.id +'"><tr><td width="10" rowspan="2">&nbsp;</td><td width="350">'+file.name+'</td><td width="100">'+plupload.formatSize(file.size)+'</td><td  width="223" rowspan="2">&nbsp;</td></tr><tr><td colspan="2" id="tdProess_'+file.id +'">&nbsp;</td></tr></table><br/>'
			});
		},

		UploadProgress: function(up, file) {
			//document.getElementById("tdProess_"+file.id).innerHTML = '<span>' + file.percent + "%</span>";
			//document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
			$("#"+button).find("p").html(file.percent+"%");
			if(file.percent==100)
			{
				$("#"+button).find("p").hide();
			}
			else
			{
				$("#"+button).find("p").show();
			}
		},
        FileUploaded:function(up,file,o)
		{
			var json = eval("("+o.response+")");
			//alert(json.path);
			$("#"+button).find("img")[0].src = json.path;
			$("#"+button).find("#imgPath").val(json.path);
			//$.post("?act=upload&op=saveFile",{name:file.name,path:json.path},function(data){});
		},
		UploadComplete:function(up,o)
		{
			 
		},
		Error: function(up, err) {
			document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message;
		}
	}
});
 uploader.init();
 return uploader;
}

 up1 = newUploader("up1","status1");
 up2 = newUploader("up2","status2");
 up3 = newUploader("up3","status3");
 up4 = newUploader("up4","status4");

$(function(){
	setHeaderPos("推荐管理");
		 $("#ulList").find("li").each(function(idx){
			 var objli = $(this);
			 objli.find("#btnPost").click(function(){
				 $("#pic").val(objli.find("#imgPath").val());
				 $("#dbsubject").val(objli.find("#subject").val());
				 $("#id").val(idx+1);
				 $("#post").val("1");
				 $("#form")[0].submit();
				 });
			 objli.find("#btnUnpost").click(function(){
				 //$("#pic").val(objli.find("#imgPath")[0].src);
				 //$("#subject").val(objli.find("#subject")[0].value);
				 $("#id").val(idx+1);
				 $("#post").val("-1");
				 $("#form")[0].submit();
				 });
			 });
		 
});
function saveResult(st)
{
	alert("success");
}
</script>
{/literal}
